import Vue from 'vue'
import i18n from './i18n/i18n'
import App from './App.vue'
import router from './script/router'
import store from './script/store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import * as echarts from 'echarts'
import filter from './script/filter'
import directive from './script/directive'
import instance from './script/config/http'
import './style/common.scss'
import './style/iconfont.css'
import { environment } from './models/environment'
import { message } from './script/util/message'
import CancelBtn from './components/button/CancelBtn'
import './mock'

Vue.prototype.$http = instance
Vue.prototype.$echarts = echarts


Vue.prototype.downloadFile = function(file) {
  let url = `${environment.API_URL}${file}` 
  window.location.href = url;
}

// 初始化所有过滤器
Object.keys(filter).forEach(key => {
  Vue.filter(key, filter[key])
})

// 初始化所有指令
Object.keys(directive).forEach(key => {
  Vue.directive(key, directive[key])
})

Vue.use(ElementUI)
Vue.prototype.$message = message
Vue.component('CancelBtn', CancelBtn)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
